﻿{include file="public/header" /}
	<form method="post" class="form-x" action="{if $data.id}?id={$data.id}{/if}">
	<div class="panel admin-panel">
		<div class="panel-head"><strong>{:lang('currency')['edit']}</strong></div>
		<br/>
		<div class="form-group">
			<div class="label">
				<label for="type">{:lang('label')['type']}</label>
			</div>
			<div class="field">
				<select class="input input-auto" id="type" name="type">
					<option {if $data.type == 1} selected {/if} value="1">总管理</option>
					<!-- <option {if $data.type == 2} selected {/if} value="2">城市管理</option> -->
				</select>
			</div>
		</div>
		<input class="hidden" name="pid"/><!--占位-->
		<div id="city" class="form-group {if $data.type == 2}{else}hidden{/if}">
			<div class="label">
				<label for="pid">{:lang('currency')['city']}</label>
			</div>
			{php}$provincearray = explode(',',$data['pid']);{/php}
			<div class="field">
			<ul class="list-inline">
			{volist name="province" id="provincelist"}
			<li><input id="{$provincelist.id}" {if in_array($provincelist.id,$provincearray)}checked{/if} name="pid[]" type="checkbox" value="{$provincelist.id}" /><label for="{$provincelist.id}">{$provincelist.name}</label></input></li>	
			{/volist}
			</ul>
			</div>
		</div>
		<input class="hidden" name="category"/><!--占位-->
		<div id="city" class="form-group">
			<div class="label">
				<label for="category">{:lang('label')['category']}</label>
			</div>
			{php}$categoryarray = explode(',',$data['category']);{/php}
			<div class="field">
			<ul class="list-inline">
			{volist name="category" id="categorylist"}
			<li><input id="{$categorylist.id}" {if in_array($categorylist.id,$categoryarray)}checked{/if} name="category[]" type="checkbox" value="{$categorylist.id}" /><label for="{$categorylist.id}">{$categorylist.title}</label></input></li>	
			{/volist}
			</ul>
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="username">{:lang('label')['username']}</label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="username" name="username" value="{$data.username}" size="80" placeholder="{:lang('label')['username']}" data-validate="required:{:lang('currency')['required']}" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="phone">{:lang('label')['phone']}</label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="phone" name="phone" value="{$data.phone}" size="80" placeholder="{:lang('label')['phone']}" data-validate="required:{:lang('currency')['required']}" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="password">{:lang('label')['password']}</label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="password" name="password" value="" size="80" placeholder="{:lang('label')['password']}" {if !$data.id}data-validate="required:{:lang('currency')['required']}"{/if} />
			</div>
		</div>
		<div class="form-group">
		<input class="hidden" name="auth"/><!--占位-->
		<div class="input-inline clearfix">
			<div class="label">
				<label for="auth">{:lang('label')['auth']}</label>
			</div>
			{php}$autharray = explode(',',$data['auth']);{/php}
			<div class="field">
				<ul class="list-inline">
				{volist name="menu" id="volist"}
					<li {if $i==0}class="active"{/if}>
						<input data-order="{$i}" id="check{$i}" class="check" {if in_array($volist.auth,$autharray)}checked{/if} name="auth[]" type="checkbox" value="{$volist.auth}" /><label for="check{$i}">{$volist.name}</label>
						<ul class="list-inline">
						{volist name="volist.sub" key="j" id="sublist"}
						<li>
							<input id="check{$i}{$j}" class="checksub checksub{$i}" {if in_array($sublist.auth,$autharray)}checked{/if} name="auth[]" type="checkbox" value="{$sublist.auth}" /><label for="check{$i}{$j}">{$sublist.name}</label>
						</li>	
						{/volist}
						</ul>
					</li>
					<hr/>
				{/volist}
				</ul>
			</div>
			
		</div>
		</div>
		<div class="form-button">
			<button class="button bg-main" type="submit">{:lang('form')['submit']}</button>
		</div>
		<br/>
		</div>
	</form>
	<script>
		$("#type").click(function(){
			var type = $("#type").val();
			if(type=='1'){
				$("#city").addClass('hidden');
			}else{
				$("#city").removeClass('hidden');
			}
		});
		$(".check").click(function(){
			$(".checksub"+$(this).attr('data-order')).prop("checked",$(this).prop("checked"));
		});
		$(".checksub").click(function(){
			if(!$(this).parent().parent().parent().find('input').prop("checked")){
				alert("{:lang('currency')['authtip']}");
				return false;
			}
		});
	</script>
{include file="public/footer" /}